#ifndef __POPUP_SERVER_UI_HPP__
#define __POPUP_SERVER_UI_HPP__

#include "PopupLibTypes.hpp"
#include "PopupLoggerUI.hpp"
#include "PopupDatabaseUI.hpp"

namespace Popup
{
  //============================================================================
  // API which a server UI shall implement
  //============================================================================

  //! This class defines the API which a client user interface
  //! shall implement.
  struct ServerUI
  {
    virtual ~ServerUI() {}

    //!
    virtual void onClientConnected(const User & p_client) = 0;
    
    //!
    virtual void onClientDisconnected(const User & p_client) = 0;
    
    //!
    //! Event raised when the PopupServer is about to be destroyed.
    //!
    virtual void onDestroy() = 0;

    //!
    //! \return The temporary directory which must be used in order
    //! to save the users avatar files.
    //!
    virtual std::string getResourceDir() = 0;

    //!
    //! \return The default avatar path
    //!
    virtual std::string getDefaultAvatar() = 0;
  };

  //============================================================================
  // API of a Popup server
  //============================================================================

  struct Server 
  {
    virtual ~Server() {}

    static Server *newServer(unsigned short p_port,
                             unsigned short p_maxNbConnections,
                             DatabaseUI *p_database,
                             ServerUI *p_serverUI);

    virtual void run() = 0;
  };
}

#endif // __POPUP_SERVER_UI_HPP__
